package com.hopechart.micro.common.generator;

import com.hopechart.micro.common.exception.BusinessException;
import com.hopechart.micro.common.generator.controller.ControllerGenerator;
import com.hopechart.micro.common.generator.repository.RepositoryGenerator;
import com.hopechart.micro.common.generator.service.ServiceGenerator;
import com.hopechart.micro.config.MasterDataSourceConfig;

/**
 * @author daijiang@hopechart.com
 */
public class GeneratorLauncher {

    public void executor(MasterDataSourceConfig dataSourceConfig,
                         String tableName, String modelName) {
        try {
            new RepositoryGenerator().execute(dataSourceConfig, tableName, modelName);
            new ServiceGenerator().executor(tableName, modelName);
            new ControllerGenerator().executor(tableName, modelName);
        } catch (BusinessException e) {
            throw e;
        }
    }
}
